package org.come.tt;

import org.come.Frame.NPCJfram;
import org.come.Frame.ZhuFrame;
import org.come.action.MapAction;
import org.come.control.BangBattleControl;
import org.come.socket.Agreement;
import org.come.socket.SendMessageUntil;
import org.come.until.FormsManagement;
import org.come.until.Music;
import org.come.until.NpcMenuUntil;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

public class EventSelectionMouseListener implements MouseListener {

    private final EventSelectionJpanel eventSelectionJpanel;
    private final Integer type;

    public EventSelectionMouseListener(EventSelectionJpanel eventSelectionJpanel, Integer type) {
        this.eventSelectionJpanel = eventSelectionJpanel;
        this.type = type;
    }

    // type 赛事类型 1 = 天梯 2 = 召唤兽比斗  3 = 联赛
    // index 1 = 鼠标移入 2 = 鼠标点击 3 = 鼠标移除
    private void eventHandling(Integer type, Integer index) {


        switch (type) {
            case 1:
                if (index == 1) {
                    eventSelectionJpanel.getTtBox_1_0().setVisible(false);
                    eventSelectionJpanel.getTtBox_1_1().setVisible(true);
                } else if (index == 2) {

                    // 打开了窗体
                    FormsManagement.showForm(604);
                    String mes = Agreement.getAgreement().pankinglistAgreement("8");
                    SendMessageUntil.toServer(mes);
                    Music.addyinxiao("开关窗口.mp3");
                    FormsManagement.HideForm(605);
                } else if (index == 3) {

                    eventSelectionJpanel.getTtBox_1_0().setVisible(true);
                    eventSelectionJpanel.getTtBox_1_1().setVisible(false);
                }

                break;
            case 2:
                if (index == 1) {
                    eventSelectionJpanel.getTtBox_2_0().setVisible(false);
                    eventSelectionJpanel.getTtBox_2_1().setVisible(true);
                } else if (index == 2) {

                    Music.addyinxiao("开关窗口.mp3");
                    ZhuFrame.getZhuJpanel().addPrompt2("暂未开放，敬请期待！");

                } else if (index == 3) {
                    eventSelectionJpanel.getTtBox_2_0().setVisible(true);
                    eventSelectionJpanel.getTtBox_2_1().setVisible(false);

                }

                break;
            case 3:
                if (index == 1) {
                    eventSelectionJpanel.getTtBox_3_0().setVisible(false);
                    eventSelectionJpanel.getTtBox_3_1().setVisible(true);
                } else if (index == 2) {
                    Music.addyinxiao("开关窗口.mp3");
                    ZhuFrame.getZhuJpanel().addPrompt2("暂未开放，敬请期待！");
                } else if (index == 3) {
                    eventSelectionJpanel.getTtBox_3_0().setVisible(true);
                    eventSelectionJpanel.getTtBox_3_1().setVisible(false);
                }

                break;
        }
    }


    @Override
    public void mouseClicked(MouseEvent e) {

        eventHandling(type, 2);
    }

    @Override
    public void mousePressed(MouseEvent e) {

    }

    @Override
    public void mouseReleased(MouseEvent e) {

    }

    @Override
    public void mouseEntered(MouseEvent e) {
        eventHandling(type, 1);
    }

    @Override
    public void mouseExited(MouseEvent e) {


        eventHandling(type, 3);


    }
}
